GH#915: fix: emit wu_inline_login_error hook in pre-submit catch block#922
GH#915: fix: emit wu_inline_login_error hook in pre-submit catch block#922superdav42 merged 1 commit intomainfrom
Conversation
When Promise.all(hooks.applyFilters('wu_before_inline_login_submitted'))
rejects, the catch block set login_error but did not fire the
wu_inline_login_error action. Addons that reset captcha/widgets on
login failure (via that hook) would silently not run on this path.
Add hooks.doAction('wu_inline_login_error', ...) after setting
this.login_error, mirroring the same hook emission in the AJAX
error handler. The payload wraps the message and originalError so
addon callbacks receive consistent structure regardless of which
failure path fired.
Fixes #915
📝 WalkthroughWalkthroughAdds a missing failure hook emission in the inline login flow when the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merge SummaryIssue: #915 — quality-debt: emit Change: Added Files modified: Testing: JS syntax validated (node); logic mirrors the existing AJAX error handler pattern from PR #913. aidevops.sh v3.10.1 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 2m on this as a headless worker. Overall, 13s since this issue was created. |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
assets/js/checkout.js (1)
1244-1249: Optional: payload shape differs from the AJAX error path on Line 1312.The new emission passes a normalized
{ data: { message }, originalError }object, but the AJAX failure path at Line 1312 still forwards the raw jqXHRerrorwheremessagelives aterror.responseJSON.data.message. Addon listeners therefore have to branch on payload shape to read the message. Consider normalizing the AJAX path to the same shape in a follow-up so both failure paths exposeerror.data.messageuniformly (note: this would be a behavior change for existing listeners, so it's out of scope for this fix).Also applies to: 1312-1312
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@assets/js/checkout.js` around lines 1244 - 1249, The 'wu_inline_login_error' hook currently emits a normalized payload in the inline login path via hooks.doAction(..., { data: { message: this.login_error }, originalError: err }, field_type) but the AJAX failure branch still forwards the raw jqXHR error (error with message at error.responseJSON.data.message); update the AJAX error handler that triggers hooks.doAction('wu_inline_login_error', ...) to construct the same normalized shape (e.g., { data: { message: /* extract responseJSON.data.message or fallback */ }, originalError: error }) so addon listeners can read error.data.message consistently while preserving originalError for debugging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@assets/js/checkout.js`:
- Around line 1244-1249: The 'wu_inline_login_error' hook currently emits a
normalized payload in the inline login path via hooks.doAction(..., { data: {
message: this.login_error }, originalError: err }, field_type) but the AJAX
failure branch still forwards the raw jqXHR error (error with message at
error.responseJSON.data.message); update the AJAX error handler that triggers
hooks.doAction('wu_inline_login_error', ...) to construct the same normalized
shape (e.g., { data: { message: /* extract responseJSON.data.message or fallback
*/ }, originalError: error }) so addon listeners can read error.data.message
consistently while preserving originalError for debugging.
|
Performance Test Results Performance test results for 2637b4f are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
What
Emit
wu_inline_login_erroraction in thecatchblock that handles rejection ofwu_before_inline_login_submittedpromises.Why
When
Promise.all(hooks.applyFilters('wu_before_inline_login_submitted', [], field_type))rejects (e.g. a captcha promise rejects), the catch block setthis.login_errorand returnedfalsebut never fired thewu_inline_login_erroraction. Addons that listen to that hook to reset captcha widgets or other UI state would silently no-op on this failure path, even though the AJAX error path already fires the hook correctly.How
After setting
this.login_error, call:This mirrors
assets/js/checkout.js:1293(the AJAX error handler) while wrapping the error in a structured object so addon callbacks receive consistent data regardless of which failure path fired.Verification
wu_before_inline_login_submittedfilter that returns a rejected promise.wu_inline_login_errorfires and any registered callback (e.g. captcha reset) runs.wu_inline_login_errorstill fires on a normal AJAX login failure (regression check on the AJAX path).Resolves #915
aidevops.sh v3.10.1 plugin for OpenCode v1.3.17 with claude-sonnet-4-6 spent 2m and 6,791 tokens on this as a headless worker.
Summary by CodeRabbit